home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
bbsutil
/
bsrc_250.zip
/
ZRECEIVE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-15
|
40KB
|
1,093 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software, Co. */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / Freely Available<tm> Software. */
/* \ 1011 / */
/* ------ */
/* */
/* (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
/* */
/* */
/* Zmodem file reception module */
/* */
/* */
/* For complete details of the licensing restrictions, please refer */
/* to the License agreement, which is published in its entirety in */
/* the MAKEFILE and BT.C, and also contained in the file LICENSE.250. */
/* */
/* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
/* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
/* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
/* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT BIT BUCKET */
/* SOFTWARE CO. AT ONE OF THE ADDRESSES LISTED BELOW. IN NO EVENT */
/* SHOULD YOU PROCEED TO USE THIS FILE WITHOUT HAVING ACCEPTED THE */
/* TERMS OF THE BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER */
/* AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO. */
/* */
/* */
/* You can contact Bit Bucket Software Co. at any one of the following */
/* addresses: */
/* */
/* Bit Bucket Software Co. FidoNet 1:104/501, 1:343/491 */
/* P.O. Box 460398 AlterNet 7:491/0 */
/* Aurora, CO 80046 BBS-Net 86:2030/1 */
/* Internet f491.n343.z1.fidonet.org */
/* */
/* Please feel free to contact us at any time to share your comments about */
/* our software and/or licensing policies. */
/* */
/* */
/* This module is based largely on a similar module in OPUS-CBCS V1.03b. */
/* The original work is (C) Copyright 1986, Wynn Wagner III. The original */
/* authors have graciously allowed us to use their code in this work. */
/* */
/*--------------------------------------------------------------------------*/
/* Include this file before any other includes or defines! */
#include "includes.h"
/*--------------------------------------------------------------------------*/
/* Local routines */
/*--------------------------------------------------------------------------*/
int RZ_ReceiveData (byte *, int);
int RZ_32ReceiveData (byte *, int);
int RZ_InitReceiver (void);
int RZ_ReceiveBatch (FILE *);
int RZ_ReceiveFile (FILE *);
int RZ_GetHeader (void);
int RZ_SaveToDisk (long *);
void RZ_AckBibi (void);
/*--------------------------------------------------------------------------*/
/* Private declarations */
/*--------------------------------------------------------------------------*/
static long DiskAvail;
static long filetime;
static char realname[64];
/*--------------------------------------------------------------------------*/
/* Private data */
/*--------------------------------------------------------------------------*/
/* Parameters for ZSINIT frame */
#define ZATTNLEN 32
static char Attn[ZATTNLEN + 1]; /* String rx sends to tx on
* err */
static FILE *Outfile; /* Handle of file being
* received */
static int Tryzhdrtype; /* Hdr type to send for Last
* rx close */
static char isBinary; /* Current file is binary
* mode */
static char EOFseen; /* indicates cpm eof (^Z)
* was received */
static char Zconv; /* ZMODEM file conversion
* request */
static int RxCount; /* Count of data bytes
* received */
static char Upload_path[PATHLEN]; /* Dest. path of file being
* received */
static long Filestart; /* File offset we started
* this xfer from */
/*--------------------------------------------------------------------------*/
/* GET ZMODEM */
/* Receive a batch of files. */
/* returns TRUE (1) for good xfer, FALSE (0) for bad */
/* can be called from f_upload or to get mail from a WaZOO Opus */
/*--------------------------------------------------------------------------*/
int get_Zmodem (char *rcvpath, FILE *xferinfo)
{
char namebuf[PATHLEN];
int i;
char *p;
char *HoldName;
long t;
#ifdef DEBUG
show_debug_name ("get_Zmodem");
#endif
filetime = 0;
IN_XON_ENABLE ();
/* Secbuf = NULL;*/
Outfile = NULL;
z_size = 0;
Rxtimeout = 100;
Tryzhdrtype = ZRINIT;
(void) strcpy (namebuf, rcvpath);
Filename = namebuf;
(void) strcpy (Upload_path, rcvpath);
p = Upload_path + strlen (Upload_path) - 1;
while (p >= Upload_path && *p != '\\')
--p;
*(++p) = '\0';
HoldName = HoldAreaNameMunge(&called_addr);
(void) sprintf (Abortlog_name, "%s%s.Z\0",
HoldName, Hex_Addr_Str (&remote_addr));
DiskAvail = zfree (Upload_path);
if (((i = RZ_InitReceiver ()) == ZCOMPL) ||
((i == ZFILE) && ((RZ_ReceiveBatch (xferinfo)) == OK)))
{
XON_DISABLE ();
XON_ENABLE (); /* Make sure xmitter is
* unstuck */
return 1;
}
CLEAR_OUTBOUND ();
XON_DISABLE (); /* Make sure xmitter is
* unstuck */
send_can (); /* transmit at least 10 cans */
t = timerset (200); /* wait no more than 2
* seconds */
while (!timeup (t) && !OUT_